from new_rmasm import lexer
from new_rmasm import parser
from new_rmasm import translator
from new_rmasm import temp_code

ap = parser.AstParser(lexer.Lexer(r"""
{   
    asd:
    jump -asd
    asd:
}
"""))

s = ap.segment_ast()
env = temp_code.AstsTranslateEnv()
tran = s.translate(env)

if env.warnings:
    print(f"=======WARNING ({len(env.warnings)}) =========")
    for i in env.warnings:
        print(i)

tct = translator.TCTranslator(tran)
r = tct.translate()
if not r.endswith('\nend'):
    r += '\nend'
print(r)
